<template>
  <div id="app">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <van-tabbar route active-color="#CEA62A" v-if="isTabShow" class="nav">
      <van-tabbar-item replace to="/home" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item replace to="/topic" icon="description"
        >专题</van-tabbar-item
      >
      <van-tabbar-item replace to="/category" icon="apps-o"
        >分类</van-tabbar-item
      >
      <van-tabbar-item replace to="/cart" icon="shopping-cart-o"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item replace to="/user" icon="friends-o"
        >我的</van-tabbar-item
      >
    </van-tabbar>
    <router-view />
  </div>
</template>

<script>
export default {
  data() {
    return {
      isTabShow: true,
    };
  },
  watch: {
    $route: function (to) {
      var arr = ["home", "topic", "category", "user", "cart"];
      if (arr.includes(to.name)) {
        this.isTabShow = true;
      } else {
        this.isTabShow = false;
      }
    },
  },
  created() {
    var userInfo = {
      openId: "66",

      nickName: "赵六",

      avatarUrl:
        "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIbWFEIJj8IpGeHM7dGic1aTFZALjWcMm9ltWfFiaQfVRYticWBfgGfzXWMt2EkJWiaicPtftHAlWxUibxQ/132",
    };

    var openId = userInfo.openId;

    localStorage.setItem("userInfo", JSON.stringify(userInfo));

    localStorage.setItem("openId", openId);
  },
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // text-align: center;
  color: #2c3e50;
  // z-index: 10000;
  // background-color: #eeeeee;
}
nav {
  // padding: 30px;
  z-index: 100000;
  background-color: #fff;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
* {
  padding: 0;
  margin: 0;
}
::v-deep an-nav-bar{
  position: fixed;
  top: 0;
  left: 0;
}
</style>
